export function bluetoothPrint(mac_address, printValue) {
    console.log("进入print-----")
    try {
        let BluetoothAdapter = plus.android.importClass("android.bluetooth.BluetoothAdapter");
        let UUID = plus.android.importClass("java.util.UUID");
        let uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
        let BAdapter = BluetoothAdapter.getDefaultAdapter();
        let device = BAdapter.getRemoteDevice(mac_address);
        plus.android.importClass(device);
        let bluetoothSocket = device.createInsecureRfcommSocketToServiceRecord(uuid);
        plus.android.importClass(bluetoothSocket);
        if (!bluetoothSocket.isConnected()) {
            console.log('检测到设备未连接，尝试连接....');
            console.log("连接中...")
 
            bluetoothSocket.connect();
        }
        console.log('设备已连接');
 
        if (bluetoothSocket.isConnected()) {
            console.log("test begin")
            let outputStream = bluetoothSocket.getOutputStream();
            console.log("outputStream:%o", outputStream);
            plus.android.importClass(outputStream);
 
            console.log("qrCodeArr:%o", printValue)
            printValue.forEach(item => {
                if (device) {
                    console.log("this.BleDevice.getName():%o", device.getName())
                }
                console.log("version log -------2021-999999")
                console.log("print qr-----")
                let bytes = plus.android.invoke(item, 'getBytes', 'GB2312');
                // let bytes = plus.android.invoke(item, 'getBytes', 'gbk');   
                outputStream.write(bytes);
                outputStream.flush();
            })
 
            device = null //这里关键
            bluetoothSocket.close(); //必须关闭蓝牙连接否则意外断开的话打印错误
            localStorage.setItem("lastConnectAddress", mac_address)
        }
 
    } catch (error) {}

  }